import java.util.Random;
import java.util.Scanner;

/**
 * Created by asus on 2017/5/18.
 */
public class OurAchv extends SetNum{
    //我们已写好的重要了类有： 产生高级题目的类NewProject；计算类Postfix
    public static void main (String args []) {


        //程序过程
    /*
      一 询问级别
     {
*/
        int right =0;
        SetNum Num =new SetNum();
        Random in = new Random();
        Scanner out = new Scanner(System.in);
        OneProject a = new OneProject();
        Postfix b = new Postfix();
        String choose = "Y";
        while (choose.equalsIgnoreCase("Y")) {
            System.out.println("Which level do you need:");
            System.out.println("We have 1 ,2 , 3");
            int level = out.nextInt();
            System.out.println("How many do you need");
            int need = out.nextInt();
            for (int i = 0;i<need;i++) {
                if (level==1||level==2||level==3) {
           // 级别1：
             //   使用类： 单一运算符题目类{1.整数2.分数    （switch case）  }；Postfix类
                    if (level==1){

                        int num = in.nextInt(2);
                        switch (num){
                            case 0:
                                String pro =a.Project();
                                String pro2 = pro+"="+"?";
                                System.out.println(pro2);
                                String answe = out.nextLine();
                                int answer = out.nextInt();
                                //判断对错
                                if (answer==Integer.parseInt(b.Count(pro))){
                                    System.out.println("TRUE");
                                    right++;
                                }
                                else
                                    System.out.println("Wrong");
                                    System.out.println("The true is:"+b.Count(pro));
                                break;
                            default:
                                    String re = out.nextLine();
                                    int first=Num.getA();
                                    int last=Num.getA();
                                    int first2=Num.getA();
                                    int last2=Num.getA();
                                    RationalNumber score = new RationalNumber(first,last);
                                    RationalNumber score2 = new RationalNumber(first2,last2);
                                    int which = in.nextInt(4);

                                switch (which){
                                    case 0:
                                        System.out.println(first+"/"+last+" "+"+"+" "+first2+"/"+last2+"="+"?");
                                        String result = out.nextLine();
                                        if (result.equalsIgnoreCase(String.valueOf(score.add(score2))) ){
                                            System.out.println("TRUE");
                                            right++;
                                        }
                                        else {
                                            System.out.println("Wrong");
                                            System.out.println("The true is:"+score.add(score2));
                                        }
                                        break;
                                    case 1:
                                        System.out.println(first+"/"+last+" "+"-"+" "+first2+"/"+last2+"="+"?");
                                        String result1 = out.nextLine();
                                        if (result1.equalsIgnoreCase(String.valueOf(score.subtract(score2)))) {
                                            System.out.println("TRUE");
                                            right++;
                                        }
                                        else {
                                            System.out.println("Wrong");
                                            System.out.println("The true is:"+score.subtract(score2));
                                        }
                                        break;
                                    case 2:
                                        System.out.println(first+"/"+last+" "+"*"+" "+first2+"/"+last2+"="+"?");
                                        String result2 = out.nextLine();
                                        if (result2.equalsIgnoreCase(String.valueOf(score.multiply(score2)))) {
                                            System.out.println("TRUE");
                                            right++;
                                        }
                                        else {
                                            System.out.println("Wrong");
                                            System.out.println("The true is:"+score.multiply(score2));
                                        }
                                        break;
                                    case 3:
                                        System.out.println(first+"/"+last+" "+"/"+" "+first2+"/"+last2+"="+"?");
                                        String result3 = out.nextLine();
                                        if (result3.equalsIgnoreCase(String.valueOf(score.divide(score2)))) {
                                            System.out.println("TRUE");
                                            right++;
                                        }
                                        else {
                                            System.out.println("Wrong");
                                            System.out.println("The true is:"+score.divide(score2));
                                        }
                                        break;
                                }

                        }


                    }
                    // 级别2：
                    if (level==2){
                        String pro = a.Two();
                        String pro1 = pro+"="+"?";
                        System.out.println(pro1);
                        String answe = out.nextLine();
                        int answer = out.nextInt();
                        //判断对错
                        if (answer == Integer.parseInt(b.Count(pro))){
                            System.out.println("TRUE");
                            right++;
                        }
                        else
                            System.out.println("Wrong");
                        System.out.println("The true is:"+b.Count(pro));
                    }

             //    使用类：
               //         双运算符类；Posefix
           // 级别3：
             //      使用类：NewProject类；Postfix类
                    if (level==3){
                        NewProject NewPro = new NewProject();
                        String result = NewPro.JudgeAllpart();
                        System.out.println(result+"="+"?");
                        String answe = out.nextLine();
                        double answer = out.nextDouble();
                        if (answer==Double.valueOf(b.Count(result))){
                            System.out.println("TRUE");
                            right++;
                        }
                        else
                            System.out.println("Wrong");
                            System.out.println("The true is:"+b.Count(result));
                    }

                }
                else
                {
                    System.out.println("Wrong message");
                    System.out.println("Test again?(Y/N)");
                    choose = out.nextLine();
                    choose = out.nextLine();

                }
            }
    /*
     二 询问题目数
        for{}
        switch case
      要求
       1.统计正确数
       2. 最后显示正确率
       3.回答错误显示正确答案
       if{}
       4.将题目写入文件
       5.最后询问是否重新开始
       while( equalsIqnoreCase )
*/
            System.out.println("Right:"+right);
            System.out.println("Do you want to try again?(Y/N)");
            choose = out.nextLine();
            choose = out.nextLine();
        }
    }











}
